/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       aseloader.h
 * Author:     sergio
 * Created on: 2009-05-08
 *
 **********************************************************************************************************************/

#ifndef ASELOADER_H_
#define ASELOADER_H_

#include "meshloader.h"

namespace mGameEngine
{
namespace Graphics
{

class AseLoader: public MeshLoader
{
private:
    static const int BUF_SIZE;
    bool readString(const char* src,int* ptr,char* str,int len);
    int readLine(const char* node, int* ptr, char* buf);
    char* readNode(const char* node, int* ptr, char* nodename, int len);
    void readMapDiffuse(char*node, int matNum);
    void readMaterial(char* node, int matNum);
    void readMaterialList(char* node);
    void readMesh(char* node);
    void readGeomObj(char* node);

    size_t _vertexCount, _faceCount;
    size_t _tVertexCount, _tFaceCount;

    Vector<Vertex> *_vertices;
    Vector<Face> *_faces;
    Vector<int> *_mtlID;
    Vector<Vector3> *_tVertices;
    Vector<Face> *_tFaces;

public:
    /**
     * Create ASE mesh file loader with no file name specified.
     */
    AseLoader();

    /**
     * Create ASE mesh file loader with specified file name.
     * @param filename ASE mesh file name to load
     */
    AseLoader(const String &filename);

    /**
     * Destroy ASE mesh file loader.
     */
    ~AseLoader();

    /**
     * Load mesh from ASE file.
     */
    void load();
};

}
}

#endif // ASELOADER_H_
